import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";

var _class, _temp;

import React from "react";
import intl from "cpaas-front/lib/utils/intl";
import { BlockContainer } from "./index.style";
import SectionTitle from "../_components/SectionTitle";
import ConfigItem from "../_components/ConfigItem";
import withFormOperate from "../_components/withFormOperate";
import { getMemoizedAssets, getStaticGif } from "./util";
import MotionTitle from "../_components/MotionTitle";

var FormInputConfig = withFormOperate(_class = (_temp = /*#__PURE__*/function (_React$Component) {
  _inherits(FormInputConfig, _React$Component);

  function FormInputConfig() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, FormInputConfig);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(FormInputConfig)).call.apply(_getPrototypeOf2, [this].concat(args)));
    _this.memoizedInput = getMemoizedAssets(_this.props.styleCounts.input, "input");
    _this.memoizedEmailInput = getMemoizedAssets(_this.props.styleCounts.input, "input/email-input");
    _this.memoizedPasswordInput = getMemoizedAssets(_this.props.styleCounts.input, "input/password-input");
    _this.memoizedNumberInput = getMemoizedAssets(_this.props.styleCounts.input, "input/number-input");
    _this.memoizedLov = getMemoizedAssets(_this.props.styleCounts.input, "input/Lov");
    _this.memoizedTextarea = getMemoizedAssets(_this.props.styleCounts.input, "input/text-input");
    _this.getRequiredColor = getMemoizedAssets(_this.props.styleCounts.formColor, "input/required-color");
    _this.getMotions1 = getStaticGif(2, "input/motions", "png", "1");
    _this.getMotions2 = getStaticGif(2, "input/motions", "png", "2");
    return _this;
  }

  _createClass(FormInputConfig, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          value = _this$props.value,
          schema = _this$props.schema,
          handleChange = _this$props.handleChange; // const disabledArr = [0, 1, 2, 3, 4].map(v => v !== value.style);

      var textInputs = this.memoizedInput(schema);
      var numberInputs = this.memoizedNumberInput(schema);
      var emailInputs = this.memoizedEmailInput(schema);
      var passwordInputs = this.memoizedPasswordInput(schema);
      var textareaInputs = this.memoizedTextarea(schema);
      var lovInputs = this.memoizedLov(schema);
      return React.createElement(BlockContainer, {
        id: "inputs-config"
      }, React.createElement(SectionTitle, {
        titleTail: "Input",
        title: "\u8F93\u5165",
        style: {
          marginTop: 24
        }
      }), React.createElement(ConfigItem, {
        title: intl.get("cpaas.cpaasTheme.page.textField").d("文本输入框"),
        simple: true,
        items: textInputs,
        defaultSelected: value.input,
        onChange: handleChange("input")
      }), React.createElement(ConfigItem, {
        title: intl.get("cpaas.cpaasTheme.page.emailField").d("邮件输入框"),
        simple: true,
        items: emailInputs,
        defaultSelected: value.input,
        onChange: handleChange("input")
      }), React.createElement(ConfigItem, {
        cols: 2,
        title: intl.get("cpaas.cpaasTheme.page.password").d("密码输入框"),
        items: passwordInputs,
        defaultSelected: value.input,
        onChange: handleChange("input")
      }), React.createElement(ConfigItem, {
        simple: true,
        title: intl.get("cpaas.cpaasTheme.page.numberField").d("数字输入框"),
        className: "number",
        items: numberInputs,
        onChange: handleChange("input") // disabledItems={disabledArr}
        ,
        defaultSelected: value.input
      }), React.createElement(ConfigItem, {
        simple: true,
        title: intl.get("cpaas.cpaasTheme.page.lov").d("弹出选择框（Lov）") // title="弹出选择框(LOV)"
        ,
        className: "number",
        items: lovInputs,
        onChange: handleChange("input"),
        defaultSelected: value.input
      }), React.createElement(ConfigItem, {
        title: intl.get("cpaas.cpaasTheme.page.textarea").d("文本域输入框"),
        simple: true,
        items: textareaInputs,
        onChange: handleChange("input") // disabledItems={disabledArr}
        ,
        defaultSelected: value.input
      }), React.createElement(ConfigItem, {
        className: "motion-config" // title="必填框颜色（系统中所有必填色统一，包含选择框等）"
        ,
        title: intl.get("cpaas.cpaasTheme.page.requiredColorMsg").d("必填框颜色（系统中所有必填色统一，包含选择框等）"),
        items: this.getRequiredColor(schema),
        defaultSelected: value.formColor,
        onChange: handleChange("formColor") // onChange={handleChange("requiredStyle")}

      }), React.createElement(ConfigItem, {
        className: "motion-config",
        title: React.createElement(MotionTitle, {
          text: intl.get("cpaas.cpaasTheme.page.animation").d("动效")
        }),
        items: this.getMotions1(schema),
        defaultSelected: value.inputMotion,
        onChange: handleChange("inputMotion")
      }), React.createElement(ConfigItem, {
        className: "motion-config",
        title: React.createElement(MotionTitle, {
          text: intl.get("cpaas.cpaasTheme.page.animation").d("动效")
        }),
        items: this.getMotions2(schema),
        defaultSelected: value.inputMotion,
        onChange: handleChange("inputMotion")
      }));
    }
  }]);

  return FormInputConfig;
}(React.Component), _temp)) || _class;

export { FormInputConfig as default };
